package com.imcoke.abchat.web.mapper;

import com.imcoke.abchat.domain.RelationShip;
import org.apache.ibatis.annotations.*;

/**
 * @Author ccoke
 * @Description
 * @Date: 10:38 2018-01-13
 */
@Mapper
public interface RelationShipMapper {
    /*
    * 建立关系
    * */
    @Insert("INSERT INTO tb_relationship VALUES(#{id},#{aid},#{bid},#{time})")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", before = false, resultType = Long.class)
    int insertRelationShip(RelationShip relationShip);

    /*
    * 通过用户id查询关系
    * */
    @Select("SELECT * FROM tb_relationship WHERE aid = #{userId} or bid = #{userId} ")
    RelationShip selectRelationShipByUserId(@Param("userID") Long userId);

    /*
    * 通过id删除关系
    * */
    @Delete("DELETE FROM tb_relationship WHERE id = #{id}")
    int deleteRelationShipById(@Param("id") Long id);


}
